package com.qf.service.impl;

import com.qf.entity.Workorder;
import com.qf.mapper.WorkorderMapper;
import com.qf.service.WorkorderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author lenovo
 * @version V1.0
 * @Date 2021/10/4 18:03
 */
@Service
public class WorkorderServiceImpl implements WorkorderService {

    @Autowired
    private WorkorderMapper workorderMapper;

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public void add(Workorder workorder) {

        int i = workorderMapper.insert(workorder);
        if (i != 1){
            System.out.println("添加失败");
            throw new RuntimeException("添加失败");
        }
    }

    @Override
    public List<Workorder> findAllByPid(Integer pid) {
        return workorderMapper.findAllByPid(pid);
    }
}
